package com.hamizhong.iflowers.web.action.admin.statics;

import net.sf.json.JSONObject;

import com.hamizhong.iflowers.service.IColorService;
import com.hamizhong.iflowers.utils.MyConstants;
import com.hamizhong.iflowers.web.base.MyBaseAjaxAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.ColorVO;
import com.hamizhong.iflowers.web.vo.IObjectVO;

public class AjaxUpdateColorAction extends MyBaseAjaxAction {
	
	private IColorService iColorService = null;
	
	public IColorService getiColorService() {
		return iColorService;
	}
	public void setiColorService(IColorService iColorService) {
		this.iColorService = iColorService;
	}
	
	@Override
	protected JSONObject doRequest() {
		logger.info("...invoke...AjaxUpdateColorAction...");
		String colorName = getRQ().getParameter("colorName");
		String colorId = getRQ().getParameter("colorId");
		String sortId = getRQ().getParameter("sortId");
		String remarks = getRQ().getParameter("remarks");
		IOPResultDto<IObjectVO> resultDto = new IOPResultDto<IObjectVO>();
		ColorVO colorVO = new ColorVO();
		colorVO.setColorName(colorName);
		colorVO.setColorId(colorId);
		colorVO.setSortId(Integer.valueOf(sortId));
		colorVO.setRemarks(remarks);
		resultDto = iColorService.updateColor(colorVO);
		JSONObject jo = new JSONObject();
		if(resultDto.isSuccess()) {
			jo.put("result", MyConstants.AJAX_SUCCESS);
		}else {
			jo.put("result", MyConstants.AJAX_FAILED_ALERT);
			jo.put("msg", resultDto.getErrorMSG());
		}
		return jo;
	}

}
